//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101
//#include "stdafx.h"
#include "BlackVarianceTermStructure.h"
using namespace Cephei::QL::Termstructures::Volatility::Equityfx;
#include <gen/QL/Times/Calendar.h>
#include <gen/QL/Times/DayCounter.h>
#include <gen/QL/Times/Period.h>
#include <gen/QL/Termstructures/Volatility/Equityfx/BlackVolTermStructure.h>
using namespace Cephei::QL::Times;
#define HANDLE
#define ABSTRACT
#undef STRUCT
Cephei::QL::Termstructures::Volatility::Equityfx::CBlackVarianceTermStructure::CBlackVarianceTermStructure (boost::shared_ptr<QuantLib::BlackVarianceTermStructure>& childNative, Object^ owner) : CBlackVolTermStructure(CBlackVarianceTermStructure::typeid)
{
#ifdef HANDLE
	_phBlackVarianceTermStructure = NULL;
#endif
	_ppBlackVarianceTermStructure = &childNative;
    _ppBlackVolTermStructure = new boost::shared_ptr<QuantLib::BlackVolTermStructure> (boost::dynamic_pointer_cast<QuantLib::BlackVolTermStructure> (*_ppBlackVarianceTermStructure));
}
Cephei::QL::Termstructures::Volatility::Equityfx::CBlackVarianceTermStructure::CBlackVarianceTermStructure (QuantLib::BlackVarianceTermStructure& childNative, Object^ owner) : CBlackVolTermStructure(CBlackVarianceTermStructure::typeid)
{
#ifdef HANDLE
	_phBlackVarianceTermStructure = NULL;
#endif
	_ppBlackVarianceTermStructure = new boost::shared_ptr<QuantLib::BlackVarianceTermStructure> (&childNative);
    _ppBlackVolTermStructure = new boost::shared_ptr<QuantLib::BlackVolTermStructure> (boost::dynamic_pointer_cast<QuantLib::BlackVolTermStructure> (*_ppBlackVarianceTermStructure));
    _BlackVarianceTermStructureOwner = owner;
    _BlackVolTermStructureOwner = owner;
}

Cephei::QL::Termstructures::Volatility::Equityfx::CBlackVarianceTermStructure::CBlackVarianceTermStructure (CBlackVarianceTermStructure^ copy) : CBlackVolTermStructure(CBlackVarianceTermStructure::typeid)
{
#ifdef HANDLE
	_phBlackVarianceTermStructure = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppBlackVarianceTermStructure = new boost::shared_ptr<QuantLib::BlackVarianceTermStructure> (copy->GetShared());
        _ppBlackVolTermStructure = new boost::shared_ptr<QuantLib::BlackVolTermStructure> (boost::dynamic_pointer_cast<QuantLib::BlackVolTermStructure> (*_ppBlackVarianceTermStructure));
    }
}
Cephei::QL::Termstructures::Volatility::Equityfx::CBlackVarianceTermStructure::CBlackVarianceTermStructure (System::Type^ t) : CBlackVolTermStructure(CBlackVarianceTermStructure::typeid)
{
#ifdef HANDLE
	_phBlackVarianceTermStructure = NULL;
#endif
	if (!t->IsSubclassOf(CBlackVarianceTermStructure::typeid))
		throw gcnew Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Termstructures::Volatility::Equityfx::CBlackVarianceTermStructure::CBlackVarianceTermStructure (QuantLib::Handle<QuantLib::BlackVarianceTermStructure>& childNative, Object^ owner)  : CBlackVolTermStructure(CBlackVarianceTermStructure::typeid)
{
	_phBlackVarianceTermStructure = &childNative;
	_ppBlackVarianceTermStructure = &static_cast<boost::shared_ptr<QuantLib::BlackVarianceTermStructure>>(childNative.currentLink());
    _ppBlackVolTermStructure = new boost::shared_ptr<QuantLib::BlackVolTermStructure> (boost::dynamic_pointer_cast<QuantLib::BlackVolTermStructure> (*_ppBlackVarianceTermStructure));
    _BlackVarianceTermStructureOwner = owner;
}
Cephei::QL::Termstructures::Volatility::Equityfx::CBlackVarianceTermStructure::CBlackVarianceTermStructure (QuantLib::Handle<QuantLib::BlackVarianceTermStructure> childNative)  : CBlackVolTermStructure(CBlackVarianceTermStructure::typeid)
{
	_phBlackVarianceTermStructure = &childNative;
	_ppBlackVarianceTermStructure = &static_cast<boost::shared_ptr<QuantLib::BlackVarianceTermStructure>>(childNative.currentLink());
    _ppBlackVolTermStructure = new boost::shared_ptr<QuantLib::BlackVolTermStructure> (boost::dynamic_pointer_cast<QuantLib::BlackVolTermStructure> (*_ppBlackVarianceTermStructure));
}
#endif
#ifdef STRUCT
Cephei::QL::Termstructures::Volatility::Equityfx::CBlackVarianceTermStructure::CBlackVarianceTermStructure (QuantLib::BlackVarianceTermStructure childNative)  : CBlackVolTermStructure(CBlackVarianceTermStructure::typeid)
{
#ifdef HANDLE
	_phBlackVarianceTermStructure = NULL;
#endif
	_ppBlackVarianceTermStructure = new boost::shared_ptr<QuantLib::BlackVarianceTermStructure> (new QuantLib::BlackVarianceTermStructure (childNative));
    _ppBlackVolTermStructure = new boost::shared_ptr<QuantLib::BlackVolTermStructure> (boost::dynamic_pointer_cast<QuantLib::BlackVolTermStructure> (*_ppBlackVarianceTermStructure));
}
#endif

Cephei::QL::Termstructures::Volatility::Equityfx::CBlackVarianceTermStructure::~CBlackVarianceTermStructure ()
{
    if (_ppBlackVarianceTermStructure != NULL)
    {
	    delete _ppBlackVarianceTermStructure;
        _ppBlackVarianceTermStructure = NULL;
    }
}
Cephei::QL::Termstructures::Volatility::Equityfx::CBlackVarianceTermStructure::!CBlackVarianceTermStructure ()
{
    if (_ppBlackVarianceTermStructure != NULL)
    {
	    delete _ppBlackVarianceTermStructure;
    }
}
QuantLib::BlackVarianceTermStructure& Cephei::QL::Termstructures::Volatility::Equityfx::CBlackVarianceTermStructure::GetReference ()
{
    if (_ppBlackVarianceTermStructure == NULL) throw gcnew NativeNullException ();
	return **_ppBlackVarianceTermStructure;
}
boost::shared_ptr<QuantLib::BlackVarianceTermStructure>& Cephei::QL::Termstructures::Volatility::Equityfx::CBlackVarianceTermStructure::GetShared ()
{
    if (_ppBlackVarianceTermStructure == NULL) throw gcnew NativeNullException ();
	return *_ppBlackVarianceTermStructure;
}
QuantLib::BlackVarianceTermStructure* Cephei::QL::Termstructures::Volatility::Equityfx::CBlackVarianceTermStructure::GetPointer ()
{
    if (_ppBlackVarianceTermStructure == NULL) throw gcnew NativeNullException ();
	return &**_ppBlackVarianceTermStructure;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::BlackVarianceTermStructure>& Cephei::QL::Termstructures::Volatility::Equityfx::CBlackVarianceTermStructure::GetHandle ()
{
	if (_phBlackVarianceTermStructure == NULL)
	{
		_phBlackVarianceTermStructure = new Handle<QuantLib::BlackVarianceTermStructure> (*_ppBlackVarianceTermStructure);
	}
	return *_phBlackVarianceTermStructure;
}
#endif
bool Cephei::QL::Termstructures::Volatility::Equityfx::CBlackVarianceTermStructure::HasNative () 
{
	return (_ppBlackVarianceTermStructure != NULL);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

